package com.springstudy.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

import java.util.Properties;

/**
 * @author Tamako
 * @since 2025/1/22 16:45
 */
@Configuration
@ComponentScan("com.springstudy")
@EnableWebMvc
public class SpringMvcConfig {
//    @Bean
//    public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
//        SimpleMappingExceptionResolver exceptionResolver = new SimpleMappingExceptionResolver();
//        //不管什么异常，统一响应一个友好页面
//        exceptionResolver.setDefaultErrorView("/error1.html");
//        Properties properties = new Properties();
//        //配置异常类型和视图的映射
//        properties.setProperty("java.lang.Exception", "/error1.html");
//        properties.setProperty("java.lang.RuntimeException", "/error2.html");
//        exceptionResolver.setExceptionMappings(properties);
//        return exceptionResolver;
//    }
}
